package com.runen.wnhz.runen.presenter.iPresenter;

import android.util.Log;

import com.runen.wnhz.runen.data.entity.BaseEntity;
import com.runen.wnhz.runen.data.entity.ShopDetail;
import com.runen.wnhz.runen.presenter.BasePresenter;
import com.runen.wnhz.runen.presenter.Contart.PublicmContart;
import com.runen.wnhz.runen.presenter.model.PublicmModel;

import java.util.HashMap;
import java.util.Map;

import javax.inject.Inject;

import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2018/6/1 0001.
 */

public class IPublicmDetailsPresenter extends BasePresenter<PublicmModel, PublicmContart.DetailsView> {
    @Inject
    public IPublicmDetailsPresenter(PublicmModel mModel, PublicmContart.DetailsView mView) {
        super(mModel, mView);
    }

    public void getShopDetail() {
        Map<String, String> map = new HashMap<>();
        map.put("token", mView.getToken());
        map.put("type_id", mView.getTypeId());
        map.put("shop_id", mView.getShopId());
        map.put("sdate", mView.getSdate());
        map.put("edate", mView.getEdate());
        Log.d("request", mView.getToken() + mView.getTypeId() + mView.getShopId() + mView.getSdate() + mView.getEdate());
        mModel.getShopDetail(map).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<BaseEntity<ShopDetail>>() {
                    @Override
                    public void onCompleted() {
                        Log.d("IPublicmDetai","-----onCompleted-----");
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.d("IPublicmDetai","-----onError-----");
                    }

                    @Override
                    public void onNext(BaseEntity<ShopDetail> shopDetailBaseEntity) {
                        Log.d("shopDetailBaseEntity","------shopDetailBaseEntity------");
                        Log.d("shopDetailBaseEntity", shopDetailBaseEntity.toString());
                        mView.updateUI(shopDetailBaseEntity);
                        mView.updateUI(shopDetailBaseEntity);
                    }
                })
        ;
    }
}
